import http from '@/api'
import { Result, UniCloudParams } from '../interface'
import { MenuApi } from '../interface/menu'

/**
 * 新增菜单
 * @param params
 */
export const addMenuApi = (params: UniCloudParams<MenuApi.Menu>) => {
  return http.post(`/mo-admin/addMenu`, params)
}

/**
 * 删除菜单
 * @param params
 * @returns
 */
export const deleteMenuApi = (params: UniCloudParams<MenuApi.Menu>) => {
  return http.post(`/mo-admin/deleteMenu`, params)
}

/**
 * 更新菜单
 * @param params
 * @returns
 */
export const updateMenuApi = (params: UniCloudParams<MenuApi.Menu>) => {
  return http.post(`/mo-admin/updateMenu`, params)
}

/**
 * 获取全部菜单
 * @returns
 */
export const getMenuTreeApi = () => {
  return http.post<MenuApi.Menu[]>(`/mo-admin/getMenuTree`)
}

/**
 * 获取parent菜单树
 * @returns
 */
export const getMenuTreeParentApi = () => {
  return http.post<MenuApi.Menu[]>(`/mo-admin/getMenuTreeParent`)
}
